<template>
    <div id="CompanyProfileIndex">
      <product-img :productImg="banner_mobile"/>
      <paragraph-intro :ParagraphIntro_title="getText('title')" :ParagraphIntro_content="getText('content')"/>
      <contact-method v-for="(list,index) in contactList" :key="index" :info="list"  :imgWidth="imgWidth"/>
      <div class="fillLine"></div>
      <product-img :productImg="ad_banner_mobile"/>
      <channel-provider :info="channelList" :ulWidth="ulWidth"/>
      <div class="fillLine"></div>
    </div>
</template>

<script>
  import productImg from '@/components/mobile/product/productImg'
  import ParagraphIntro from '@/components/mobile/brand/ParagraphIntro'
  import contactMethod from '@/components/mobile/CompanyProfile/contactMethod'
  import ChannelProvider from '@/components/mobile/CompanyProfile/ChannelProvider'
  export default {
        name: "CompanyProfileIndex",
      data(){
          return{
            banner_mobile:'',
            ad_banner_mobile:'',
            contactList:{},
            channelList:{},
            imgWidth:0,
            ulWidth:0,
          }
      },
    computed:{
      lang:{
        get(){
          let storageData = window.sessionStorage.getItem('lang');
          if(this.$store.state.lang!==storageData){
            this.$store.dispatch('toChangeLang', storageData);    //同步操作
          }
          return this.$store.getters.getLang;
        },
        set(){}
      },
    },
      methods: {
        getText(text) {
          let str = 'CompanyProfile.' + text;
          return this.$t(str);
        },
        getContactText(text) {
          let str = 'CompanyProfile.contactInfo' + text;
          return this.$t(str);
        },
        getScreen: function () {
          this.imgWidth = (document.body.clientWidth) / 6;
          this.ulWidth = (document.body.clientWidth - 3) / 4;
        },
        changeCurrentPageText(route){
          //显示当前页
          let lang=this.lang;
          if(route==='/MallIndex'){
            if(lang==='en'){
              this.$store.dispatch('toChangeCurrentPageText','mall');
            }else{
              this.$store.dispatch('toChangeCurrentPageText','商城');
            }
          }
          if(route==='/brandIndex'){
            if(lang==='en'){
              this.$store.dispatch('toChangeCurrentPageText','brand');
            }else{
              this.$store.dispatch('toChangeCurrentPageText','品牌');
            }
          }
          if(route==='/CompanyProfileIndex'){
            if(lang==='en'){
              this.$store.dispatch('toChangeCurrentPageText','company profile');
            }else{
              this.$store.dispatch('toChangeCurrentPageText','公司介绍');
            }
          }
          if(route==='/theNewsList'){
            if(lang==='en'){
              this.$store.dispatch('toChangeCurrentPageText','news list');
            }else{
              this.$store.dispatch('toChangeCurrentPageText','新闻');
            }
          }
          if(route==='/NewsDetails'){
            if(lang==='en'){
              this.$store.dispatch('toChangeCurrentPageText','news details');
            }else{
              this.$store.dispatch('toChangeCurrentPageText','新闻详情');
            }
          }
        },
        //获取公司介绍信息
        getCompanyProfile() {
          this.$store.dispatch('toChangeLoadIngVisible',true);
          let _this = this;
          this.axios.get(domain.url+'introduction/api/get_introduction', {
            params: {
              language: _this.lang,
            }
          })
            .then(function (response) {
              let data=response.data;
              _this.banner_mobile=data.banner_mobile;
              _this.ad_banner_mobile=data.ad_banner_mobile;
              _this.contactList=data.contact;
              _this.channelList=data.channel;
              _this.changeCurrentPageText('/CompanyProfileIndex');
              _this.$store.dispatch('toChangeLoadIngVisible',false);
            })
            .catch(function (error) {
              console.log(error);
            });
        },
      },
      components:{
        productImg:productImg,
        ParagraphIntro:ParagraphIntro,
        contactMethod:contactMethod,
        ChannelProvider:ChannelProvider,
      },
      mounted(){
        this.getScreen();
        this.getCompanyProfile();
      }
    }
</script>

<style scoped>
#CompanyProfileIndex{
  color:#000;
  background: #f5f5f5;
}
.fillLine{
  width:100%;
  height:10px;
  background: #f5f5f5;
}
</style>
